/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Form = require("form");
	var scatterCheckInBiz = require("../business/scatterCheckInBiz");
	var processData = require("../store/processData");
    var instance = {
        renderForm: function (widget,nonMemberType,roomTypeMap,roomTypes) {
        	var roomTypeFormData = widget.get("roomTypeFormData");
       		roomTypeFormData = [];
       		
        	for(var i in roomTypeMap){
        		var cItems = roomTypeMap[i].items;
        		var roomType = {
        				roomType:roomTypeMap[i].roomType
        		};
        		
        		var mapPkRoomType = roomTypeMap[i].roomType.pkRoomType;
        		var tRoomType = roomType;
        		
        		for(var j=0;j<roomTypes.length;j++){
        			if(roomTypes[j].roomType.pkRoomType == mapPkRoomType){
        				tRoomType = roomTypes[j];
        				break;
        			}
        		}
        		
        		var items = processData.getFormItems(widget,cItems,nonMemberType,tRoomType);
        		
    			$(".J-forms").append("<div class='J-form-" + i + "'></div>");
    			
        		var form = new Form({
        			parentNode: ".J-form-" + i,
        			model: {
        				id: i,
        				layout: "3_1",
        				defaultButton: false,
        				items: items
        			}
        		});
        		roomTypeFormData.push(form);
        		
        		for(var k=0;k<items.length;k++){
        			if(items[k].name.indexOf("standardPrice") == -1 && items[k].name.indexOf("Price_") != -1){
        				form.$("div[el-data-component="+items[k].name+"]").parent().addClass("hidden");
        			}
        		}
        		
        		form.$("div[el-data-component=hiddentext]").parent().addClass("hidden");
        		
        	}
        	widget.set("roomTypeFormData",roomTypeFormData);
        }
    };
    module.exports = instance;
});
